package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.modules.lesson.domain.Lesson;
import com.zfzs.post.modules.lesson.service.dto.LessonDTO;
import com.zfzs.post.service.LessonApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wq
 * @date 2019/12/4 14:51
 * @description
 */
@RestController
@RequestMapping("lesson")
public class LessonApiController {

    @Autowired
    private LessonApiService lessonApiService;

    /**
     * 获取展业课堂页面信息
     *
     * @return
     */
    @Log("获取展业课堂页面信息")
    @PostMapping("get_lesson_info")
    public ResponseResult getLessonInfo() {
        Map<String, Object> map = lessonApiService.getLessonInfo();
        return ResponseResult.ok(map);

    }


    /**
     * 获取单个信息
     *
     * @return
     */
    @Log("获取展业课堂页面信息")
    @PostMapping("get_lesson_byId")
    public ResponseResult getLessonById(@RequestBody LessonDTO dto) {
        Lesson lesson = lessonApiService.getLessonById(dto.getLessonId());
        return ResponseResult.ok(new HashMap<String, Lesson>(1) {{
            put("lesson", lesson);
        }});

    }


}
